<template>
  <div class="app-container">
         <el-table v-loading="loading" :data="list" >
      <el-table-column label="客户名称" align="center" prop="customerName">
         <template slot-scope="scope">
           <el-link @click="openCustomer(scope.row)" :underline="false" type="primary" >{{scope.row.customerName}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="手机" align="center" prop="mobile" />
      <el-table-column label="电话" align="center" prop="telephone" />
      <el-table-column label="网址" align="center" prop="website" />
      <el-table-column label="邮箱" align="center" prop="email" />
      <el-table-column label="负责人" align="center" prop="userNickName" />
      <el-table-column label="认领时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>
      <el-table-column label="详细地址" align="center" prop="detailAddress" show-overflow-tooltip  />
      <el-table-column label="状态" align="left" prop="status" width="200" >
        <template slot-scope="scope">
              <el-tag prop="status" v-for="(item, index) in statusOptions"  :type="scope.row.status==2?'success':'danger'"   v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" prop="isAudit" >
        <template slot-scope="scope">
              <el-tag prop="isAudit" v-for="(item, index) in auditOptions"  :type="scope.row.isAudit==1?'success':'danger'"  v-if="scope.row.isAudit==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
         </el-table>
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
    
  </div>
</template>

<script>

import { getNewCustomerUsers } from "@/api/crm/customerUser";

export default {
  name: "customer",
  data() {
    return {
      
      // 遮罩层
      loading: true,
      list: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      statusOptions:[],
      auditOptions:[],
      receiveOptions:[],

    };
  },
  created() {
    this.getDicts("customer_user_status").then((response) => {
      this.statusOptions = response.data;
    });
    this.getDicts("customer_user_audit").then((response) => {
      this.auditOptions = response.data;
    });
    this.getDicts("customer_receive").then((response) => {
      this.receiveOptions = response.data;
    });
  },
  mounted() {
   
  },
  methods: {
    openCustomer(row){
      const customerId = row.customerId || this.ids
      this.$emit('open-customer',customerId);
      
    },

    getList(data) {
      this.loading = true;
      this.queryParams.type=data.type;
      this.queryParams.userIds=data.userIds;
      this.queryParams.deptId=data.deptId;
      getNewCustomerUsers(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    
   
    
  }
};
</script>
<style scoped>
 
</style>

